package exceptiontest;

public class ExceptionTest {
    public int getFirstValidInt () {
        int result;
        try {
            result = Test.readInt();
        }
        catch (Exception e) {
            result = getFirstValidInt();
        }
        return result;
    }
    public double getX (double y) throws XLessThanZeroException, XGreaterThanOneException {
        double x = Math.log(y);
        if (x < 0) {
            throw new XLessThanZeroException(y);
        }
        else if (x > 1) {
            throw new XGreaterThanOneException();
        }
        return x;
    }
    public double solve (double y) {
        double x;
        try {
            x = Test.solve2(y);
        }
        catch (XLessThanZeroException e) {
            x = -1;
        }
        catch (XGreaterThanOneException e) {
            x = -2;
        }
        return x;
    }
}
